package com.xiaozhi.controller.entitycontroller;

import com.xiaozhi.entity.Discussion;
import com.xiaozhi.service.DiscussionService;
import com.xiaozhi.utils.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static org.apache.ibatis.ognl.DynamicSubscript.all;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 烟尘
 * @since 2023-03-15
 */
@RestController
@RequestMapping("/discussion")
public class DiscussionController {
    @Autowired
    private DiscussionService discussionService;
    @ApiOperation("搜索讨论")
    @ResponseBody
    @GetMapping("/searchdis/{text}")
    public ResponseResult<List<Discussion>> search(@PathVariable("text") String text){
        List<Discussion> all = discussionService.getAllByCondition(text);
        return ResponseResult.success(all);
    }
    @ApiOperation("热门内容")
    @ResponseBody
    @GetMapping("/topcontent")
    public ResponseResult<List<Discussion>> topContent(){
        List<Discussion> all = discussionService.getAllByTop();
        return ResponseResult.success(all);
    }
    @ApiOperation("推荐内容")
    @ResponseBody
    @GetMapping("/recommendcontent")
    public ResponseResult<List<Discussion>> recommendContent(){
        List<Discussion> all = discussionService.getAllByRecommend();
        return ResponseResult.success(all);
    }
    @ApiOperation("讨论内容")
    @ResponseBody
    @GetMapping("/getAllMes/{id}")
    public ResponseResult<Discussion> recommendContent(@PathVariable("id") Integer id){
        Discussion mes = discussionService.getAllMes(id);
        System.out.println(mes);
        return ResponseResult.success(mes);
    }

}
